package com.example.sentrytester;

import io.sentry.SentryClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * @author ME
 */
@SpringBootApplication
public class SentryTesterApplication implements CommandLineRunner {
	private static Logger logger = LoggerFactory.getLogger(SentryTesterApplication.class);

	@Autowired
	SentryClient sentryClient;

	public static void main(String[] args) {
		SpringApplication.run(SentryTesterApplication.class, args);
	}

	@Override
	public void run(String... args) throws Exception {
		logger.info("Sending a testing message in INFO level");
		sentryClient.sendMessage("Testing Message.");
		logger.info("Sending an exception.");
		sentryClient.sendException(new RuntimeException("This is a testing message."));

		logger.info("Sleeping for a while(5 seconds) to wait response.");
		Thread.sleep(5000);
	}
}
